Skip to content

Notebook: three code cells (1. Install, 2. Mount Google Drive, 3. Run preprocessing) - #267

Merged
guijacquemet merged 4 commits into
mainfrom
claude/notebook-three-cells
Nov 10, 2026
Merged

guijacquemet merged 4 commits into
mainfrom
claude/notebook-three-cells

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Owner request of 10 November 2026. Like the lab's ZeroCostDL4Mic and NucleiSky notebooks, notebooks/MorphoBricks_Preprocessing.ipynb now has three code cells instead of one. Each cell sits under a Markdown heading that explains it.

Unchanged: RELEASE_TAG v0.5.0, RELEASE_REF fd7afd339bcaab7579c806a28a65bb7ecebe940c, the install target and extras, DEVELOPMENT_OVERRIDE, SETUP_RECORD, and PreprocessingNotebook(describe=True) with the same display(app). This PR changes only how the code is split into cells, the Markdown, and the docs and tests that describe them. The v0.5.1 release PR moves RELEASE_REF later.

The cells

  1. # @title 1. Install MorphoBricks preprocessing: the previous bootstrap code without the Drive mount. It still checks for a nearby checkout, an installed package or the pinned GitHub install, sets EXTRAS to notebook,zarr on Colab, checks that notebook_ui imports, and prints the version report followed by "Next: run cell 2 …, then cell 3 …". It does not ask for a restart. Running it again installs nothing that is already there (tested).
  2. # @title 2. Mount Google Drive: drive.mount("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/content/drive") inside the Colab guard, with the same refusal as before when the mount fails. Outside Colab it prints one line: "Not Google Colab: there is no Google Drive to mount here, so nothing was done." It raises no error there.
  3. # @title 3. Run preprocessing: builds and displays the app.
    • If SETUP_RECORD was never filled, it stops with a RuntimeError saying "run cell 1 (Install MorphoBricks preprocessing) first". That covers a fresh kernel and a cell 1 that failed. It does not fail with an ImportError.
    • On Colab without /content/drive/MyDrive, it stops and names cell 2. Nothing falls back silently to the runtime's disk.
    • No cell runs another cell's code.

The code-cell metadata is copied from the old cell (source hidden, JupyterLab hide-code lock).

Tests

  • tests/test_notebook_file.py:
    • The notebook layout: an introduction, then exactly three heading + code pairs in order, with these titles.
    • What each cell does: the install cell alone has the pin, pip and the version report. The Drive cell only mounts. The run cell only shows the app and never installs, mounts or calls _install_preprocessing.
    • RELEASE_CALLS and release_call() are kept. Exactly one PreprocessingNotebook(...) call across all cells, and it is in cell 3.
    • A new AST check: /content strings and google imports appear only inside the Colab guard. No magics.
    • Real-kernel runs (nbclient): all three cells outside Colab, where cell 2 must print its single line; all three with a faked google.colab; and cell 3 alone in a fresh kernel, which must give a RuntimeError naming cell 1.
  • tests/test_notebook_setup.py:
    • All the existing bootstrap tests are kept. They now run the cells in one shared namespace, and /content/drive is replaced by a temporary folder that the fake drive.mount fills.
    • New tests:
      • cell 1 neither mounts Drive nor shows the app;
      • cell 1 run twice installs once;
      • cell 2 outside Colab prints one line and does nothing;
      • cell 2 alone on Colab only mounts;
      • cell 3 without cell 1 names cell 1, on and off Colab;
      • cell 3 after a failed cell 1 still names cell 1;
      • cell 3 on Colab without Drive names cell 2, and works once cell 2 has run;
      • cell 3 outside Colab needs no cell 2.

Docs

  • docs/colab-release-check.md section A: the smoke check now covers the three cells, including running them out of order and running cell 1 twice.
  • docs/user_guide.md §1 and its Colab section, README.md, AGENTS.md (Notebook target row, the notebook-file tests, §7 code cells), the plan's Q58 amendment and a CHANGELOG "Unreleased" entry.

Verification

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc

Owner request of 10 November 2026, as in ZeroCostDL4Mic and NucleiSky:
the single code cell of the shipped notebook is split into
1. Install MorphoBricks preprocessing, 2. Mount Google Drive and
3. Run preprocessing, each under a Markdown heading that explains it.
RELEASE_REF, the install target and PreprocessingNotebook(describe=True)
are unchanged.

Cell 2 prints a one-line note outside Colab. Cell 3 run before cell 1
stops naming cell 1 (not an ImportError), and on Colab without Drive it
stops naming cell 2; no cell runs another. Tests: the three cells in
order and each one's part, Colab-only code inside the guard (ast), cell 1
run twice installs once, the cells out of order, and real-kernel runs with
and without a faked google.colab and of cell 3 alone. Docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
The fixture stays within the code rules' 60 executable lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
A Windows temporary path in a Python string literal holds backslash
escapes; the forward-slash form is the same folder there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants